<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <!-- 上述3个meta标签*必须*放在最前面，任何其他内容都*必须*跟随其后！ -->
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0,user-scalable=no,minimal-ui">
    <meta name="description" content="">
    <meta name="author" content="">
    <link rel="icon" href="../img/asset-favico.ico">
    <title>登录</title>

    <link rel="stylesheet" href="../css/page-health-login.css" />
</head>

<body data-spy="scroll" data-target="#myNavbar" data-offset="150">
    <div id="app">
        <!-- 页面头部 -->
        <div class="top-header">
            <span class="f-left"><i class="icon-back"></i>返回</span>
            <span class="center">千锋健康</span>
            <span class="f-right"><a href="health-index.html" style="color: white">游客</a></span>
        </div>
        <!-- 页面内容 -->
        <div class="contentBox">
            <div class="login">
                <form id='login-form' class="input-group">
                    <div class="input-row">
                        <label>用户名</label>
                        <input id='account' type="text" v-model="TUser.username" placeholder="请输入用户名">
                    </div>
                    <div class="input-row">
                        <label>密码</label>
                        <input id='password' type="password" v-model="TUser.password" placeholder="请输入密码">
                    </div>
<!--                    <button class="btn cancel-btn" @click="login">登录</button>-->
                    <div class="btn cancel-btn"  @click="login">登录</div>
                    <div class="btn cancel-btn"  @click="index">取消</div>
                </form>
            </div>
        </div>
    </div>
    <!-- 页面 css js -->
</body>
<script src="../js/vue.js"></script>
<script src="../js/elementui/index.js"></script>
<script src="../js/axios-0.18.0.js"></script>
<script>
    new Vue({
        el:"#app",
        data:{
            TUser:{
                username:"",
                password:""
            },
            location:""
        },
        methods:{

            login(){
                axios.defaults.withCredentials=true;
                axios({
                    url: "http://localhost:81/login",
                    method: "post",
                    params:this.TUser
                }).then(resp=>{
                    let result = resp.data;
                    //alert(result)
                    //保存登录成功后的jwt字符串
                    if (result.code == 1000){
                        localStorage.setItem("token",result.data);
                        location.href = "/pages/health-index.html"
                    }
                })
                // axios.post("",this.TUser)
                // .then(resp=>{
                //         if(resp.data.flag){
                //             //执行成功，提示信息
                //             this.$message({
                //                 type:'success',
                //                 message:resp.data.message
                //             });
                //            this.location="health-index.html";
                //         }else {
                //             this.$message.error(resp.data.message);
                //         }
                // });
            },
            index(){
               window.location()
            }
        }

    })
</script>